a[200][200];
main(n,m,i,j,b)
{
	unsigned r,p;
	for(gets(&n);~scanf("%d%d",&n,&m);printf("%u\n",r))
	{
		for(j=0;j<n;j++)
			for(i=0;i<m*2;i++)
				scanf("%d",&a[i][j]);

		for(i=0,r=-1;i<m;i++,b+=p,r=r<b?r:b)
			for(b=j=0,p=-1;j<n;j++){
				p=p<a[i*2+1][j]?p:a[i*2+1][j];
				b+=a[i*2][j]-a[i*2+1][j];
			}
	}
}
